/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: XMQ
 * Date: 2022-06-13
 * Time: 6:14
 */
class Book{
    boolean checkedOut = false;
    Book book;
    Book(boolean checkOut){
        checkedOut = checkOut;
    }
    void checkIn(){
        checkedOut = false;
    }
    protected void finalize() throws Throwable {
        if(checkedOut)
            System.out.println("Error: checked out");
        super.finalize();
    }
}
public class Test {
    public static void main(String[] args) {
        Book book = new Book(true);
        book.checkIn();
        new Book(true);//error
        System.gc();
    }
        public static int[] twoSum(int[] numbers, int target) {
        // a + b = target  -> target - b = a;
        int[] ret = new int[2];
        // int left = 0;
        // int right = numbers.length-1;
        // while(left <= right){
        //     int mid = left + (right - left) / 2;
        //     if(target - mid > 0){

        //     }
        // }
        int i = 0;
        int j = numbers.length-1;
        while(numbers[i] + numbers[j] != target){
            if(numbers[j] + numbers[i] > target){
                j--;
            }
            if(numbers[j] + numbers[i] < target){
                i++;
            }
        }
        ret[0] = i+1;
        ret[1] = j+1;
        return ret;
    }

    public static void main1(String[] args) {
        int[] nums = {2,7,8,11,14};
        twoSum(nums,9);
        System.out.println(" ");
    }
}
